<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>示例4</title>
    <script>
        function Person() {
            this.name = "张三";
            this.age = 18;
        }
        // 定义一个构造函数 
        function Student() {
            this.hobby = "打球";
        }
        let person = new Person();
        // 修改 Student 类型的原型为一个 person 对象，实现继承 Person 
        Student.prototype = person;
        // 在原型上绑定方法 
        Student.prototype.show = function () {
            alert("我是：" + this.name + "，我的爱好是：" + this.hobby);
        };
        let stu = new Student();
        console.log("stu.name =", stu.name); // 张三 
        console.log(stu);
        console.log("stu instanceof Student", stu instanceof Student); //true 
        console.log("stu instanceof Person", stu instanceof Person); //true 
        console.log("stu instanceof Object", stu instanceof Object); //true 
    </script>


</head>

<body></body>

</html>